<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>

    <script src="<c:url value="/resources/core/jquery.1.10.2.min.js" />"></script>
    <script src="<c:url value="/resources/core/jquery.autocomplete.min.js" />"></script>
    <link href="<c:url value="/resources/core/main.css" />" rel="stylesheet">
<title>jQuery ,Autocomplete,spring example</title>
</head>
<body>
<h2>Auto complete</h2>

<div>
    <input type="text"  id="w-input-search" value="">
		<span>
			<button id="w-button-search" type="button">Search</button>
		</span>
</div>

<script>
    $(document).ready(function() {

        $('#w-input-search').autocomplete({
            serviceUrl: '${pageContext.request.contextPath}/getTags',
            paramName: "tagName",
            delimiter: ",",
            transformResult: function(response) {

                return {

                    suggestions: $.map($.parseJSON(response), function(item) {

                        return { value: item.tagName, data: item.id };

                    })

                };

            }

        });


    });
</script>

</body>
</html>